package com.buglife.video.convert.util;

import java.io.File;
import java.io.FileOutputStream;

import org.springframework.web.multipart.MultipartFile;


public class Upload {
    public static File uploadFile(MultipartFile video, File dir, String fileName) {
        
        if (!video.isEmpty()) {
            try {
                if (!dir.exists()) {
                    dir.mkdirs();
                }
                File file = new File(dir.getPath() + "/" + fileName);
                file.createNewFile();
                FileOutputStream fout = new FileOutputStream(file);
                fout.write(video.getBytes());
                fout.close();
                return file;
            } catch (Exception e) {
            }
        }
        return null;
    }
}
